/**
 * com.cnhis.his.customer.service.Vao2Service.java
 */
package com.mbmed.doctor.homepage.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.commons.mapper.ModelVo;
import com.mbmed.doctor.homepage.bo.Vao2Bo;
import com.mbmed.doctor.homepage.mapper.Vao2;

/**
 * @file  Vao2Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Vao2服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-10-08 12:11:26
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/vao2")
@Component
public class Vao2Service {
	
	private static Logger logger = Logger.getLogger(Vao2.class);
	
	@Autowired
	private Vao2Bo vao2Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Vao2> getAll() throws Exception{
        List<Vao2> list = new ArrayList<Vao2>();
        return vao2Bo.getAll();        
    }
	
	
	/**
     * 病案保存
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Path("/exechomrhomepageupdate")
	@Produces({MediaType.APPLICATION_JSON})
	public ModelVo execHomrHomepageUpdate(
			@FormParam("lxml") java.lang.String lxml,
			@FormParam("empid") java.lang.String empid,
			@FormParam("empcode") java.lang.String empcode,
			@FormParam("empname") java.lang.String empname,
			@FormParam("upvae") java.lang.String upvae,
			@FormParam("tablelist") java.lang.String tablelist,
			@FormParam("luid") java.lang.String luid,
			@FormParam("lmac") java.lang.String lmac,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		ModelVo modelVo = new ModelVo();
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		
		paramsMap.put("res",-1);
		paramsMap.put("lxml", lxml);
		paramsMap.put("empid", Integer.parseInt(empid));
		paramsMap.put("empcode", empcode);
		paramsMap.put("empname", empname);
		paramsMap.put("upvae", Integer.parseInt(upvae));
		paramsMap.put("tablelist",tablelist);
		paramsMap.put("luid",luid);
		paramsMap.put("lmac",lmac);
		vao2Bo.execHomrHomepageUpdate(paramsMap);
		int res =   (int) paramsMap.get("res");
		
		modelVo.setResult(res+"");
	    return modelVo;

	}
	
	
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Vao2 getVao2(@PathParam("id") String id) throws Exception{
    	Vao2 vao2 = null;
    	return vao2Bo.get(id);        
    }
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Vao2 saveVao2(
			@FormParam("vao01") java.lang.Integer vao01,
			@FormParam("vaa01") java.lang.Integer vaa01,
			@FormParam("vaa07") java.lang.Integer vaa07,
			@FormParam("vaf01") java.lang.Integer vaf01,
			@FormParam("acf01") java.lang.Integer acf01,
			@FormParam("vao06") java.lang.Integer vao06,
			@FormParam("vao07") java.lang.Integer vao07,
			@FormParam("vao08") java.lang.Integer vao08,
			@FormParam("vao09") java.lang.Integer vao09,
			@FormParam("vao10") java.lang.Byte vao10,
			@FormParam("vao11") java.lang.Byte vao11,
			@FormParam("bak01a") java.lang.Integer bak01a,
			@FormParam("cam01") java.lang.Integer cam01,
			@FormParam("bak01b") java.lang.Integer bak01b,
			@FormParam("vao15") java.lang.String vao15,
			@FormParam("abx01") java.lang.String abx01,
			@FormParam("vao17") java.lang.Byte vao17,
			@FormParam("vao18") java.lang.Byte vao18,
			@FormParam("vao19") java.util.Date vao19,
			@FormParam("bce03a") java.lang.String bce03a,
			@FormParam("vao21") java.util.Date vao21,
			@FormParam("bce03b") java.lang.String bce03b,
			@FormParam("vao22") java.lang.Byte vao22,
			@FormParam("vao24") java.lang.Byte vao24,
			@FormParam("vao25") java.lang.Byte vao25,
			@FormParam("vao26") java.lang.String vao26,
			@FormParam("iaa01") java.lang.Integer iaa01,
			@FormParam("iad03") java.lang.String iad03,
			@FormParam("bgp01") java.lang.String bgp01,
			@FormParam("ady01") java.lang.String ady01,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Vao2 vao2 = new Vao2();
		vao2.setVao01(vao01);
		vao2.setVaa01(vaa01);
		vao2.setVaa07(vaa07);
		vao2.setVaf01(vaf01);
		vao2.setAcf01(acf01);
		vao2.setVao06(vao06);
		vao2.setVao07(vao07);
		vao2.setVao08(vao08);
		vao2.setVao09(vao09);
		vao2.setVao10(vao10);
		vao2.setVao11(vao11);
		vao2.setBak01a(bak01a);
		vao2.setCam01(cam01);
		vao2.setBak01b(bak01b);
		vao2.setVao15(vao15);
		vao2.setAbx01(abx01);
		vao2.setVao17(vao17);
		vao2.setVao18(vao18);
		vao2.setVao19(vao19);
		vao2.setBce03a(bce03a);
		vao2.setVao21(vao21);
		vao2.setBce03b(bce03b);
		vao2.setVao22(vao22);
		vao2.setVao24(vao24);
		vao2.setVao25(vao25);
		vao2.setVao26(vao26);
		vao2.setIaa01(iaa01);
		vao2.setIad03(iad03);
		vao2.setBgp01(bgp01);
		vao2.setAdy01(ady01);

		return vao2 = vao2Bo.save(vao2);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeVao2(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return vao2Bo.remove(id);

	}
	
}
